package test;

import java.util.Random;

/**
 * @author chihb
 * @create-time 2024/6/19 22:24
 * @description
 */
public class Captcha {
    public static void main(String[] args) {
        System.out.println(getNum(3));
    }

    private static String getNum(int n) {
        Random r = new Random();
        String code = "";
        for (int i = 0; i < n; i++) {
            int type = r.nextInt(3);//0,1,2
            switch (type) {
                case 0 -> code += r.nextInt(10);
                case 1 -> {
                    char ch = (char) (r.nextInt(26) + 65);  //A-Z
                    code += ch;
                }
                case 2 -> {
                    char ch2 = (char) (r.nextInt(26) + 97);//a-z
                    code += ch2;
                }
            }
        }
        return code;
    }
}
